import time
import RPi.GPIO as GPIO
import os
import atexit

atexit.register(GPIO.cleanup)
GPIO.setmode(GPIO.BOARD)
# 设置引脚为输入和输出
GPIO.setwarnings(False)
GPIO.setup(7, GPIO.IN)

while True:
    if GPIO.input(7) == 1:
        print("有路障")
    else:
        print("可前行")
    time.sleep(0.5)
